package GUI;


import javax.swing.*;

import java.awt.*;
import java.util.*;
import model.*;


public class PlayerPanel extends JPanel implements Observer{
   Observable playerSubject;
   private Player player;
   JLabel title, territory, troop, technology, food, turn;
   Clock turnclock;
   int turnNumber = 0;

   public PlayerPanel(Observable _Subject){
	   playerSubject = _Subject;

	   player = (Player)playerSubject;
	   playerSubject.addObserver(this);
	   setLayout(new GridLayout(4, 2, 10, 10));	   
	   setBorder (BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder (), "Player Information"));
	   
	   title = new JLabel(player.getName() +  "'s Game: ");
	   JLabel placeholder = new JLabel("       ");
	   territory = new JLabel("Territory: " + player.getTerritoryAmount());
	   troop = new JLabel("Troop: " + player.getTroopAmount());
	   technology = new JLabel("Technology:  " + player.getTechnology());
	   food = new JLabel("Food: " + player.getFood());
	   turn = new JLabel("Turn 1");
	   turnclock = new Clock();
	   
	   add(title);
       add(placeholder);
       add(turn);
       add(turnclock);
       add(territory);
       add(troop);
       add(technology);
       add(food);
       
   }
   
   public void update(Observable obs, Object arg){
	   playerSubject = obs;
	   player = (Player)playerSubject;
	    territory.setText("Territory:" + player.getTerritoryAmount());
		troop.setText("Troop:" + player.getTroopAmount());
		technology.setText("Technology:" + player.getTechnology());
		food.setText("Food:" + player.getFood());
   }
}
